﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using tuwien.auto.eibclient;

namespace KNXFramework.KNXObjects.ValueObjects.Signed
{
    internal class S32ObjectValue : IntObjectValue
    {
        public S32ObjectValue(string value)
            : base(value)
        {
        }

        public S32ObjectValue(EIBBuffer buffer)
        {
            int newValue = (buffer.data[2] << 24) | (buffer.data[3]<<16) | (buffer.data[4]<<8) | buffer.data[5];
        }

        public override void AdaptBufferBeforeSending(bool isWrite, EIBBuffer buffer)
        {
            byte[] b = new byte[6];
            b[0] = buffer.data[0];
            b[1] = buffer.data[1];
            b[2] = (byte)((m_Value & 0xff000000) >> 24);
            b[3] = (byte)((m_Value & 0xff0000) >> 16);
            b[4] = (byte)((m_Value & 0xff00) >> 8);
            b[5] = (byte)(m_Value & 0xff);

            buffer.data = b;
        }
    }
}
